package charpter13.lynx;

import java.util.LinkedHashSet;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Twelve {
	static public final String POEM = "Twas brillig, and the slithy toves\n"
			+ "Did gyre and gimble in the wabe.\n"
			+ "All mimsy were the borogoves,\n"
			+ "And the mome raths outgrabe.\n\n"
			+ "Beware the Jabberwock, my son,\n"
			+ "The jaws that bite, the claws that catch.\n"
			+ "Beware the Jubjub bird, and shun\n"
			+ "The frumious Bandersnatch.";

	public static void main(String[] args) {
		Matcher m = Pattern.compile("\\W+([a-z]\\w+)").matcher(POEM);

		Set<String> allSet = new LinkedHashSet<String>();
		while (m.find()) {
			allSet.add(m.group(1));
		}
		
		for (String string : allSet) {
			System.out.print(string + "|");
		}
		
		System.out.println(allSet.size());
	}
}
